﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Restaurant
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        Table table = new Table(new List<Article>());
        StringBuilder totalOrder = new StringBuilder();


        public Window1()
        {
            InitializeComponent();
        }

        //Drinks selection
        private void ButtonClick_SelectKamenitza(object sender, RoutedEventArgs e)
        {
            Drink kamenitza = new Drink("Kamenitza", 2);
            table.TableOrderList.Add(kamenitza);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectZagorka(object sender, RoutedEventArgs e)
        {
            Drink zagorka = new Drink("Zagorka", 2.1m);
            table.TableOrderList.Add(zagorka);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectAstika(object sender, RoutedEventArgs e)
        {
            Drink astika = new Drink("Astika", 1.9m);
            table.TableOrderList.Add(astika);
            UpdateOrderTextBlock();
        }
        private void ButtonClick_SelectAriana(object sender, RoutedEventArgs e)
        {
            Drink ariana = new Drink("Ariana", 2.3m);
            table.TableOrderList.Add(ariana);
            UpdateOrderTextBlock();
        }
        private void ButtonClick_SelectShumensko(object sender, RoutedEventArgs e)
        {
            Drink shumensko = new Drink("Shumensko", 1.8m);
            table.TableOrderList.Add(shumensko);
            UpdateOrderTextBlock();
        }
        private void ButtonClick_SelectStelaArtois(object sender, RoutedEventArgs e)
        {
            Drink stelaArtois = new Drink("Stela Artois", 1.8m);
            table.TableOrderList.Add(stelaArtois);
            UpdateOrderTextBlock();
        }
        private void ButtonClick_SelectCarlsberg330ml(object sender, RoutedEventArgs e)
        {
            Drink carlsberg330 = new Drink("Carlsberg 0.330ml", 1.85m);
            table.TableOrderList.Add(carlsberg330);
            UpdateOrderTextBlock();
        }
        private void ButtonClick_SelectCarlsberg500ml(object sender, RoutedEventArgs e)
        {
            Drink carlsberg500 = new Drink("Carlsberg 0.500ml", 2.35m);
            table.TableOrderList.Add(carlsberg500);
            UpdateOrderTextBlock();
        }

        //Salads selection
        private void ButtonClick_SelectShopskaSalad(object sender, RoutedEventArgs e)
        {
            Salad shopska = new Salad("Shopska Salad", 3.5m);
            table.TableOrderList.Add(shopska);
            UpdateOrderTextBlock();
        }

        //Desserts selection
        private void ButtonClick_SelectIcecream(object sender, RoutedEventArgs e)
        {
            Dessert icecream = new Dessert("Icecream", 2.1m);
            table.TableOrderList.Add(icecream);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectSundae(object sender, RoutedEventArgs e)
        {
            Dessert sundae = new Dessert("Sundae", 6.2m);
            table.TableOrderList.Add(sundae);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectTiramisu(object sender, RoutedEventArgs e)
        {
            Dessert tiramisu = new Dessert("Tiramisu", 4.9m);
            table.TableOrderList.Add(tiramisu);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectCremeBrulee(object sender, RoutedEventArgs e)
        {
            Dessert cremeBrulee = new Dessert("Creme Brulee", 4.9m);
            table.TableOrderList.Add(cremeBrulee);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectCremeCaramel(object sender, RoutedEventArgs e)
        {
            Dessert cremeCaramel = new Dessert("Creme Caramel", 2.5m);
            table.TableOrderList.Add(cremeCaramel);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectBrownie(object sender, RoutedEventArgs e)
        {
            Dessert brownie = new Dessert("Brownie", 3.5m);
            table.TableOrderList.Add(brownie);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectChocolateCake(object sender, RoutedEventArgs e)
        {
            Dessert chocolateCake = new Dessert("Chocolate Cake", 4.7m);
            table.TableOrderList.Add(chocolateCake);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectCaramelCake(object sender, RoutedEventArgs e)
        {
            Dessert caramelCake = new Dessert("Caramel Cake", 4.6m);
            table.TableOrderList.Add(caramelCake);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectBiscuitCake(object sender, RoutedEventArgs e)
        {
            Dessert buscuitCake = new Dessert("Biscuit Cake", 2.6m);
            table.TableOrderList.Add(buscuitCake);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectFruitcake(object sender, RoutedEventArgs e)
        {
            Dessert fruitcake = new Dessert("Fruitcake", 3.6m);
            table.TableOrderList.Add(fruitcake);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectCheesecake(object sender, RoutedEventArgs e)
        {
            Dessert cheesecake = new Dessert("Cheesecake", 4.2m);
            table.TableOrderList.Add(cheesecake);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectApplePie(object sender, RoutedEventArgs e)
        {
            Dessert applePie = new Dessert("Apple Pie", 3.1m);
            table.TableOrderList.Add(applePie);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectEclair(object sender, RoutedEventArgs e)
        {
            Dessert eclair = new Dessert("Eclair", 3.3m);
            table.TableOrderList.Add(eclair);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectCrepe(object sender, RoutedEventArgs e)
        {
            Dessert crepe = new Dessert("Crepe", 2.4m);
            table.TableOrderList.Add(crepe);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectWaffle(object sender, RoutedEventArgs e)
        {
            Dessert waffle = new Dessert("Waffle", 2.7m);
            table.TableOrderList.Add(waffle);
            UpdateOrderTextBlock();
        }

        private void ButtonClick_SelectRoastedPumpkin(object sender, RoutedEventArgs e)
        {
            Dessert roastedPumpkin = new Dessert("Roasted Pumpkin", 2.7m);
            table.TableOrderList.Add(roastedPumpkin);
            UpdateOrderTextBlock();
        }

        //updates the list of the table order in the left column textblock
        private void UpdateOrderTextBlock()
        {
            foreach (var item in table.TableOrderList)
            {
                totalOrder.AppendLine(item.ToString());
            }
            OrderDisplayTextBlock.Text = totalOrder.ToString();
            totalOrder.Clear();
        }

        //Calculates the total sum of the order of the table
        private void CalculateSumButton_Click(object sender, RoutedEventArgs e)
        {
            decimal orderSum = 0;
            foreach (var ordererItem in table.TableOrderList)
            {
                orderSum += ordererItem.Price;
            }
            OrderTotalSumTextBlock.Text = String.Format("TOTAL: {0:C}", orderSum);
        }


        //Middle column buttons event handlers
        private void ShowDrinksStackPanel_OnButtonClick(object sender, RoutedEventArgs e)
        {
            //the stack panel with the drinks buttons is shown while all the other panels remain hidden
            DrinksStackPanel.Visibility = System.Windows.Visibility.Visible;
            SaladsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            SoupsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            MealsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            DessertsStackPanel.Visibility = System.Windows.Visibility.Hidden;
        }
        private void ShowSaladsStackPanel_OnButtonClick(object sender, RoutedEventArgs e)
        {
            //the stack panel with the salads buttons is shown while all the other panels remain hidden
            SaladsStackPanel.Visibility = System.Windows.Visibility.Visible;
            DrinksStackPanel.Visibility = System.Windows.Visibility.Hidden;
            SoupsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            MealsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            DessertsStackPanel.Visibility = System.Windows.Visibility.Hidden;
        }

        private void ShowSoupsStackPanel_OnButtonClick(object sender, RoutedEventArgs e)
        {
            //the stack panel with the soups buttons is shown while all the other panels remain hidden
            SoupsStackPanel.Visibility = System.Windows.Visibility.Visible;
            DrinksStackPanel.Visibility = System.Windows.Visibility.Hidden;
            SaladsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            MealsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            DessertsStackPanel.Visibility = System.Windows.Visibility.Hidden;
        }

        private void ShowMealsStackPanel_OnButtonClick(object sender, RoutedEventArgs e)
        {
            //the stack panel with the meals buttons is shown while all the other panels remain hidden
            MealsStackPanel.Visibility = System.Windows.Visibility.Visible;
            DrinksStackPanel.Visibility = System.Windows.Visibility.Hidden;
            SaladsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            SoupsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            DessertsStackPanel.Visibility = System.Windows.Visibility.Hidden;
        }

        private void ShowDessertsStackPanel_OnButtonClick(object sender, RoutedEventArgs e)
        {
            //the stack panel with the deserts buttons is shown while all the other panels remain hidden
            DessertsStackPanel.Visibility = System.Windows.Visibility.Visible;
            DrinksStackPanel.Visibility = System.Windows.Visibility.Hidden;
            SaladsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            SoupsStackPanel.Visibility = System.Windows.Visibility.Hidden;
            MealsStackPanel.Visibility = System.Windows.Visibility.Hidden;
        }

        

        
    }
}
